<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.14.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>DM-CtrlH7-BF-DevProgram: C:/Users/ASUS/Desktop/dm-ctrlH7-balance-9025test/modules/algorithm/controller.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectlogo"><img alt="Logo" src="50x5.png"/></td>
  <td id="projectalign">
   <div id="projectname">DM-CtrlH7-BF-DevProgram<span id="projectnumber">&#160;beta 0.1</span>
   </div>
   <div id="projectbrief">C.ONE Studio Damiao Development Board Framework</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.14.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search/",'.html');
</script>
<script type="text/javascript">
$(function() { codefold.init(); });
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search',true);
  $(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(function(){initNavTree('controller_8h.html','',''); });
</script>
<div id="container">
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div class="header">
  <div class="headertitle"><div class="title">controller.h File Reference</div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="main_8h_source.html">main.h</a>&quot;</code><br />
<code>#include &quot;stdint.h&quot;</code><br />
<code>#include &quot;memory.h&quot;</code><br />
<code>#include &quot;stdlib.h&quot;</code><br />
<code>#include &quot;<a class="el" href="bsp__dwt_8h_source.html">bsp_dwt.h</a>&quot;</code><br />
<code>#include &quot;arm_math.h&quot;</code><br />
<code>#include &lt;math.h&gt;</code><br />
</div>
<p><a href="controller_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 id="header-nested-classes" class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:PID_5FErrorHandler_5Ft" id="r_PID_5FErrorHandler_5Ft"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_i_d___error_handler__t.html">PID_ErrorHandler_t</a></td></tr>
<tr class="memitem:PIDInstance" id="r_PIDInstance"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_i_d_instance.html">PIDInstance</a></td></tr>
<tr class="memitem:PID_5FInit_5FConfig_5Fs" id="r_PID_5FInit_5FConfig_5Fs"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_i_d___init___config__s.html">PID_Init_Config_s</a></td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 id="header-define-members" class="groupheader"><a id="define-members" name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a3aa069ac3980707dae1e0530f50d59e4" id="r_a3aa069ac3980707dae1e0530f50d59e4"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a3aa069ac3980707dae1e0530f50d59e4">abs</a>(x)</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 id="header-typedef-members" class="groupheader"><a id="typedef-members" name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:a0bdc4b432004a7e3e2a483a7ee1567e0" id="r_a0bdc4b432004a7e3e2a483a7ee1567e0"><td class="memItemLeft" align="right" valign="top"><a id="a0bdc4b432004a7e3e2a483a7ee1567e0" name="a0bdc4b432004a7e3e2a483a7ee1567e0"></a>
typedef enum errorType_e&#160;</td><td class="memItemRight" valign="bottom"><b>ErrorType_e</b></td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 id="header-enum-members" class="groupheader"><a id="enum-members" name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:a9ad7ec22a1ae28e9ee634a1bdd6e151e" id="r_a9ad7ec22a1ae28e9ee634a1bdd6e151e"><td class="memItemLeft" align="right" valign="top"><a id="a9ad7ec22a1ae28e9ee634a1bdd6e151e" name="a9ad7ec22a1ae28e9ee634a1bdd6e151e"></a>enum &#160;</td><td class="memItemRight" valign="bottom"><b>PID_Improvement_e</b> { <br />
&#160;&#160;<b>PID_IMPROVE_NONE</b> = 0b00000000
, <b>PID_Integral_Limit</b> = 0b00000001
, <b>PID_Derivative_On_Measurement</b> = 0b00000010
, <b>PID_Trapezoid_Intergral</b> = 0b00000100
, <br />
&#160;&#160;<b>PID_Proportional_On_Measurement</b> = 0b00001000
, <b>PID_OutputFilter</b> = 0b00010000
, <b>PID_ChangingIntegrationRate</b> = 0b00100000
, <b>PID_DerivativeFilter</b> = 0b01000000
, <br />
&#160;&#160;<b>PID_ErrorHandle</b> = 0b10000000
<br />
 }</td></tr>
<tr class="memitem:aae6ca2c44670a2e62e916e460bd30554" id="r_aae6ca2c44670a2e62e916e460bd30554"><td class="memItemLeft" align="right" valign="top"><a id="aae6ca2c44670a2e62e916e460bd30554" name="aae6ca2c44670a2e62e916e460bd30554"></a>enum &#160;</td><td class="memItemRight" valign="bottom"><b>errorType_e</b> { <b>PID_ERROR_NONE</b> = 0x00U
, <b>PID_MOTOR_BLOCKED_ERROR</b> = 0x01U
 }</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 id="header-func-members" class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a2f151ba2f498df613fea5f497aeac704" id="r_a2f151ba2f498df613fea5f497aeac704"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a2f151ba2f498df613fea5f497aeac704">PIDInit</a> (<a class="el" href="struct_p_i_d_instance.html">PIDInstance</a> *pid, <a class="el" href="struct_p_i_d___init___config__s.html">PID_Init_Config_s</a> *config)</td></tr>
<tr class="memdesc:a2f151ba2f498df613fea5f497aeac704"><td class="mdescLeft">&#160;</td><td class="mdescRight">初始化PID实例  <br /></td></tr>
<tr class="memitem:ac10c96e3f3e94b80d6df66c2c3ac53d0" id="r_ac10c96e3f3e94b80d6df66c2c3ac53d0"><td class="memItemLeft" align="right" valign="top">float&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ac10c96e3f3e94b80d6df66c2c3ac53d0">PIDCalculate</a> (<a class="el" href="struct_p_i_d_instance.html">PIDInstance</a> *pid, float measure, float ref)</td></tr>
<tr class="memdesc:ac10c96e3f3e94b80d6df66c2c3ac53d0"><td class="mdescLeft">&#160;</td><td class="mdescRight">计算PID输出  <br /></td></tr>
</table>
<a name="details" id="details"></a><h2 id="header-details" class="groupheader">Detailed Description</h2>
<div class="textblock"><dl class="section author"><dt>Author</dt><dd>Wang Hongxi </dd></dl>
<dl class="section version"><dt>Version</dt><dd>V1.1.3 </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2021/7/3 </dd></dl>
<dl class="section attention"><dt>Attention</dt><dd></dd></dl>
</div><a name="doc-define-members" id="doc-define-members"></a><h2 id="header-doc-define-members" class="groupheader">Macro Definition Documentation</h2>
<a id="a3aa069ac3980707dae1e0530f50d59e4" name="a3aa069ac3980707dae1e0530f50d59e4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3aa069ac3980707dae1e0530f50d59e4">&#9670;&#160;</a></span>abs</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define abs</td>
          <td>(</td>
          <td class="paramtype"></td>          <td class="paramname"><span class="paramname"><em>x</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">((x &gt; 0) ? x : -x)</div>
</div><!-- fragment -->
</div>
</div>
<a name="doc-func-members" id="doc-func-members"></a><h2 id="header-doc-func-members" class="groupheader">Function Documentation</h2>
<a id="ac10c96e3f3e94b80d6df66c2c3ac53d0" name="ac10c96e3f3e94b80d6df66c2c3ac53d0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac10c96e3f3e94b80d6df66c2c3ac53d0">&#9670;&#160;</a></span>PIDCalculate()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">float PIDCalculate </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_p_i_d_instance.html">PIDInstance</a> *</td>          <td class="paramname"><span class="paramname"><em>pid</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float</td>          <td class="paramname"><span class="paramname"><em>measure</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float</td>          <td class="paramname"><span class="paramname"><em>ref</em></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>计算PID输出 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pid</td><td>PID实例指针 </td></tr>
    <tr><td class="paramname">measure</td><td>反馈值 </td></tr>
    <tr><td class="paramname">ref</td><td>设定值 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>float PID计算输出</dd></dl>
<p>计算PID输出</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">PID结构体</td><td></td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">测量值</td><td></td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">期望值</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">返回空</td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a2f151ba2f498df613fea5f497aeac704" name="a2f151ba2f498df613fea5f497aeac704"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2f151ba2f498df613fea5f497aeac704">&#9670;&#160;</a></span>PIDInit()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void PIDInit </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_p_i_d_instance.html">PIDInstance</a> *</td>          <td class="paramname"><span class="paramname"><em>pid</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="struct_p_i_d___init___config__s.html">PID_Init_Config_s</a> *</td>          <td class="paramname"><span class="paramname"><em>config</em></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>初始化PID实例 </p>
<dl class="todo"><dt><b><a class="el" href="todo.html#_todo000007">Todo</a></b></dt><dd>待修改为统一的PIDRegister风格 </dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pid</td><td>PID实例指针 </td></tr>
    <tr><td class="paramname">config</td><td>PID初始化配置</td></tr>
  </table>
  </dd>
</dl>
<p>初始化PID实例</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pid</td><td>PID实例 </td></tr>
    <tr><td class="paramname">config</td><td>PID初始化设置 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="page-nav" class="page-nav-panel">
<div id="page-nav-resize-handle"></div>
<div id="page-nav-tree">
<div id="page-nav-contents">
</div><!-- page-nav-contents -->
</div><!-- page-nav-tree -->
</div><!-- page-nav -->
</div><!-- container -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a href="dir_e05d7e2b1ecd646af5bb94391405f3b5.html">modules</a></li><li class="navelem"><a href="dir_7f2cce0340e3bee62fc9457f37cf3f77.html">algorithm</a></li><li class="navelem"><a href="controller_8h.html">controller.h</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.14.0 </li>
  </ul>
</div>
</body>
</html>
